package em.model;

import java.util.Map;
import java.util.Map.Entry;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Table;
import com.jfinal.plugin.activerecord.TableMapping;

@SuppressWarnings({ "serial", "rawtypes" })
public class BaseModel<M extends BaseModel> extends Model<M> {
	
	/**
	 * 过滤传入的对象中表中没有的字段
	 * @param attrs
	 * @return
	 */
	public M setValues(Map<String, Object> attrs){
		Table t=TableMapping.me().getTable(getClass());
		Map<String,Object> temp;
		for (Entry<String, Object> e : attrs.entrySet()){
			if(t.hasColumnLabel(e.getKey())){
				super.set(e.getKey(), e.getValue());
			}
		}
		return (M)this;
	}
}
